package ct.common.util;

import java.text.DecimalFormat;

/**
 * @Author Jeremy Zheng
 * @Date 2021/2/14 21:35
 * @Version 1.0
 * 数字工具类
 * 将数据格式化为指定格式的字符串
 */
public class NumberUtil {

    public static String format(int num, int length){
        StringBuilder sb=new StringBuilder();
        for (int i=0;i<length;i++){
            sb.append("0");
        }
        DecimalFormat df =new DecimalFormat(sb.toString());
        return df.format(num);
    }

    public static void main(String[] args) {
        System.out.println(format(10,10));
    }
}
